package cn.tedu.charging.user.controller;

import cn.tedu.charging.user.service.WXLoginService;
import cn.tedu.common.pojo.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class WechatLoginController {
    @Autowired
    private WXLoginService wxLoginService;
    @GetMapping("/user/wx/login")
    public JsonResult<Integer> wxLogin(@RequestParam("code") String code,
                                       @RequestParam("nickName")String nickName){
        log.debug("微信登录:code={},nickName={}",code,nickName);
        Integer openId = wxLoginService.login(code, nickName);
        log.debug("微信登录成功，openId={}",openId);
        return JsonResult.ok(openId);
    }

}
